import org.apache.commons.codec.binary.Base64;
import org.roaringbitmap.longlong.Roaring64Bitmap;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.sql.*;

public class x {


    public static void main(String[] args) throws SQLException, IOException {


        Connection connection = DriverManager.getConnection("jdbc:mysql://doitedu:3306/jeecg-boot", "root", "root");
        PreparedStatement pst = connection.prepareStatement("select pre_select_users from rule_meta where rule_id = ? ");
        pst.setString(1,"rule-1-1");
        ResultSet resultSet = pst.executeQuery();
        resultSet.next();
        String bm64 = resultSet.getString(1);
        byte[] bytes = Base64.decodeBase64(bm64);


        Roaring64Bitmap bitmap = Roaring64Bitmap.bitmapOf();

        ByteArrayInputStream b = new ByteArrayInputStream(bytes);
        DataInputStream d = new DataInputStream(b);

        bitmap.deserialize(d);

        System.out.println(bitmap.getIntCardinality());


    }

}
